<template>
  <div class="report-form-content">
    <el-tabs type="border-card">
      <el-tab-pane label="合同借阅">
        <div class="report-form-list-content">
          <div class="report-list" v-if="contract">
            <label>合同名称：</label>
            <span>{{ contract.name }}</span>
          </div>
          <div class="report-list" v-if="contract">
            <label>合同负责人：</label>
            <span>{{ showIdLabel(userList, contract.userId, 'name') }}</span>
          </div>
          <div class="report-list" v-if="obj">
            <label>借阅人</label>
            <span>{{ showIdLabel(userList, obj.borrowUserId, 'name') }}</span>
          </div>
          <div class="report-list"  v-if="obj">
            <label>借阅人</label>
            <span>{{ showIdLabel(organizationList, obj.borrowDepartmentId, 'organizationName') }}</span>
          </div>
          <div class="report-list"  v-if="obj">
            <label>借阅类型</label>
            <span>{{ obj.borrowType === '1' ? '纸质' : '电子'  }}</span>
          </div>
          <div class="report-list">
            <label>备注</label>
          </div>
          <div class="report-list" v-if="obj">
            <span>{{ obj.remark }}</span>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="合同详情">
        <contractMainDetail v-if="obj" :contractInitialId="obj.contractInitialId" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script setup>
import {ref, watch} from 'vue'
import {doGet} from "@/config/http";
import {svc, showIdLabel, getListPageSize} from "@/config/common";
import contractMainDetail from '@/views/components/contract/contractMainDetail.vue'
import initListStore from '@/store/modules/initList'

const props = defineProps({
  contractBorrowingId: {
    required: true,
    type: String,
  }
})

let obj = ref(null)

let contract = ref(null)

// let contractTypeList = ref([]) // 合同类型
// let contractCooperationList = ref([]) // 往来单位
// let contractFeetypeList = ref([]) // 合同费用类型
// let contractTemplateList = ref([]) // 合同模版
// let bankList = ref([]) // 银行
let userList = initListStore().userList // 用户
// let governmentList = ref([]) //  政府单位
let organizationList = initListStore().organizationList // 部门
// let contractSignerList = ref([]) // 签订人
// let contractFiletypeList = ref([]) // 合同附件类型

// const initList = async () => {
//   let p1 = doGet(svc, '/contract-type/page', {pageSize: getListPageSize()}, false) // 合同类型
//   let p2 = doGet(svc, '/contract-cooperation/page', {pageSize: getListPageSize()}, false) // 往来单位
//   let p3 = doGet(svc, '/contract-feetype/page', {pageSize: getListPageSize()}, false) // 合同费用类型
//   let p4 = doGet(svc, '/contract-template/page', {pageSize: getListPageSize()}, false) // 合同模版
//   let p5 = doGet(svc, '/bank/page', {pageSize: getListPageSize()}, false) // 银行
//   let p6 = doGet(svc, '/user/page', {pageSize: getListPageSize()}, false) // 用户
//   let p7 = doGet(svc, '/government/page', {pageSize: getListPageSize()}, false) //  政府单位
//   let p8 = doGet(svc, '/organization/page', {pageSize: getListPageSize()}, false) // 部门
//   let p9 = doGet(svc, '/contract-signer/page', {pageSize: getListPageSize()}, false) // 签订人
//   let p10 = doGet(svc, '/contract-filetype/page', {pageSize: getListPageSize()}, false) // 合同附件类型

//   let resArray = await Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10])
//   contractTypeList.value = resArray[0]['records']
//   contractCooperationList.value = resArray[1]['records']
//   contractFeetypeList.value = resArray[2]['records']
//   contractTemplateList.value = resArray[3]['records']
//   bankList.value = resArray[4]['records']
//   userList.value = resArray[5]['records']
//   governmentList.value = resArray[6]['records']
//   organizationList.value = resArray[7]['records']
//   contractSignerList.value = resArray[8]['records']
//   contractFiletypeList.value = resArray[9]['records']
// }

const initObj = async (val) =>  {
  if (val) {
    obj.value = await doGet(svc, `/contract-initial-borrow/${val}`, {}, true)
    contract.value = await doGet(svc, '/contract-initial/' + obj.value.contractInitialId, {}, false)
  }
}

watch(() => props.contractBorrowingId, async val => {
  await initObj(val)
  // await initList()
},{immediate:true})

</script>

<style scoped lang="scss">
.report-form-content {
  padding: 20px;
}
.tabs-list-head-2 {
  padding-left: 0 !important;
}
.tabs-list-head-2 span {
  font-size: 22px !important;
  color: #1ac4ad !important;
}
.tabs-list-head {
  padding-left: 20px;
  display: flex;
  align-items: center;
}
.tabs-list-head span {
  font-size: 18px;
  color: #303133;
  font-weight: bold;
}
.tabs-list-head-1 {
  margin-bottom: 30px;
}
.tabs-list-type {
  display: flex;
  align-items: center;
  justify-content: center;
}
.update-log {
  width: 100%;
  margin: 30px 0;
}
.update-log-1 {
  margin-top: 0;
}
.report-list {
  /* width: 100%; */
  width: 33%;
  margin: 15px;
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
}
.report-list-a {

}
.report-list-a p {
  margin-left: 55px;
}
.report-list span:nth-child(1) {
  display: inline-block;
  width: 120px;
  text-align: right;
}
.steps {
  margin: 20px 0
}
</style>
